package com.example.giovanimarmottetoolkit;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.Button;


public class MainActivity extends Activity {
	
	private Button compassBtn, torchBtn, tempBtn;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		compassBtn = (Button)findViewById(R.id.buttonComp);
		torchBtn = (Button)findViewById(R.id.buttonTorch);
		tempBtn = (Button)findViewById(R.id.buttonTerm);
		
		final Intent intent1 = new Intent(this, BussolaActivity.class);
		final Intent intent2 = new Intent(this, TorciaActivity.class);
		//final Intent intent3 = new Intent(this, TermometroActivity.class);
		
		//Definizione Dialog Informazioni
		LayoutInflater inflater = MainActivity.this.getLayoutInflater();
		final AlertDialog info = new AlertDialog.Builder(MainActivity.this)
							   .setView(inflater.inflate(R.layout.info_layout, null))
							   .setTitle(R.string.info_title)
							   .setPositiveButton(R.string.info_pos, new DialogInterface.OnClickListener() {
								
								@Override
								public void onClick(DialogInterface dialog, int which) {
									// TODO Auto-generated method stub
									dialog.dismiss();
								}
							})
								.setNegativeButton(R.string.info_neg, new DialogInterface.OnClickListener() {
									
									@Override
									public void onClick(DialogInterface dialog, int which) {
										// TODO Auto-generated method stub
										MainActivity.this.finish();
										
									}
								})
								.create();
		
		//Settaggio bottoni
		compassBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(intent1);
				
			}
		});
		
		torchBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(intent2);
				
			}
		});
		
		tempBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//startActivity(intent3);
				info.show();
				
			}
		});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
